<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>申请转正</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
</head>
<body>
<form method="post" class="layui-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">用户姓名</label>
            <div class="layui-input-inline">
                <select name="empId" class="layui-input"  >
                    <option value="-1">全部员工</option>
                    <option th:each="d:${pname}" th:value="${d.id}" th:text="${d.empName}"></option>
                </select>
            </div>
            <label id="empId" style="color: red;display: none">请选择员工</label>
        </div>
        <br/>
        <div class="layui-inline">
            <label class="layui-form-label">申请时间</label>
            <div class="layui-input-inline">
                <input type="date" lay-verify="required" class="layui-input" name="filedDate" id="kaishi">
            </div>
        </div>
        <br/>
        <div class="layui-inline">
            <label class="layui-form-label">申请内容</label>
            <div class="layui-input-inline">
                <textarea name="filedText" style="width: 190px;height: 80px"></textarea>
            </div>
            <label id="filedText" style="color: red;display: none">请输写理由</label>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">添加</button>
        </div>
    </div>
</form>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    var $ = layui.jquery;
    $(function () {
        //获取当前时间
        var dateone =new Date();
        //获取当前年份
        var year =dateone.getFullYear();
        //获取当前月份
        var month = dateone.getMonth()+1<10 ? "0"+(dateone.getMonth()+1):(dateone.getMonth()+1);
        //获取当前日期
        var date =dateone.getDate()<10 ? "0"+dateone.getDate():dateone.getDate();

        $("#kaishi").attr("max",year+"-"+month+"-"+date);
        $("#kaishi").attr("min",year+"-"+month+"-"+date);
    })
    layui.use(['form'], function () {
        var form = layui.form;
        var layer = layui.layer;

        //监听提交
        form.on('submit(saveBtn)', function (data) {

            let theme=$(":input[name='empId']").val();
            if (theme<0){
                $("#empId").show();
                return false;
            }
            $(":input[name='empId']").click(function (){
                $("#empId").hide();
                return false;
            })
            let content=$(":input[name='filedText']").val();
            if (content==""){
                $("#filedText").show();
                return false;
            }
            $(":input[name='filedText']").click(function (){
                $("#filedText").hide();
                return false;
            })

            $.post('/positive/insertposi',data.field,function(res){
                if(res.data==="success"){
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                    parent.layui.table.reload('table-user');
                    parent.layer.msg(res.msg);
                }
            })
            return false;
        });
    });
</script>
</body>
</html>